package com.hontech.bv.utils

import kotlinx.serialization.decodeFromString
import kotlinx.serialization.encodeToString
import kotlinx.serialization.json.Json


val globalJson = Json {
    encodeDefaults = true
}

inline fun <reified T> parseJson(buf: ByteArray): T {
    return globalJson.decodeFromString( String(buf) )
}

inline fun <reified T> parseJson(s: String): T {
    return globalJson.decodeFromString( s )
}

inline fun <reified T> toJson(v: T): ByteArray {
    return globalJson.encodeToString(v).toByteArray()
}




